import { Map, View } from "@tarojs/components";
import { EventChannel } from "@tarojs/shared";
import { useLoad, usePageEvent } from "@tarojs/taro";
import { useDidShow } from "@tarojs/taro";
import { useEffect } from "react";import Taro from "@tarojs/taro";
import { useState } from "react";


const Details = () => {

  const [data,setData] = useState('')
  useLoad(() => {
    console.log('useLoaduseLoad');
    // 拿到eventChannel传递的数据
    const instance = Taro.getCurrentInstance();
      const eventChannel = instance.page.getOpenerEventChannel();
      eventChannel.on("ceshi",function(data){
        console.log("只兼容小程序的数据来了",data)
        setData(data?.data)
      })
  });


  return (
    <View className="at-article">
      <View className="at-article__h1">{data?.title}</View>
      <View className="at-article__info">
        {data?.create_time}
      </View>
      <View className="at-article__content">
        <View className="at-article__section">
          {/* <View className="at-article__h2">这是二级标题</View>
          <View className="at-article__h3">这是三级标题</View> */}
          <View className="at-article__p">
            {
              data?.content
            }
          </View>
          {/* <View className="at-article__p">这是文本段落。这是文本段落。</View> */}
        </View>
      </View>

      {/* <Map></Map> */}
    </View>
  );
};
export default Details;
